<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:g="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Company" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="company" />
	</ui:define>

	<ui:define name="content">

		<script type="text/javascript"
			src="#{request.contextPath}/scripts/it_editor.js"></script>

		<script language="javascript" type="text/javascript"
			src="#{request.contextPath}/scripts/tiny_mce/tiny_mce.js"></script>
		<script language="javascript" type="text/javascript">
		tinyMCE
		.init({
			// General options
			mode : "specific_textareas",
			language : "it",
			entity_encoding : "named",
			theme : "advanced",
			editor_selector: "tinyMceTa",
			convert_urls : false,
			plugins : "fullscreen,advlink,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template,table",
			// Theme options ... ho tolto il pulsante imgBrows.. in notizie si mettono tramite il form di upload sotto, no?
			theme_advanced_buttons1 : "fullscreen,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontsizeselect,fontselect,|,hr,|,cut,copy,paste,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,cleanup,|,code",
			theme_advanced_buttons2 : "tablecontrols,|,link,unlink",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_fonts : "Arial=Arial;Courier New=Courier New;Times New Roman=Times New Roman;",
			theme_advanced_resizing : true,
			setup : function(ed) {
				<f:verbatim rendered="#{not copertina}">
				// Add a custom button
				ed
						.addButton(
								'imgBrows',
								{
									title : 'Browser immagini',
									image : '#{facesContext.externalContext.request.contextPath}/images/img.gif',
									onclick : function() {
										// Add you own code to execute something on click
										ed.focus();
//										ed.selection.setContent('<div id="imgHere" style="text-align:center;"></div>');
										var popupWindow = window.open('#{request.contextPath}/private/page/imagesTiny.jsf',"Browser immagini","height=600,width=800,modal=yes,alwaysRaised=yes")
										popupWindow.tinyEditor = ed;
									}
								});
				</f:verbatim>
			}
		});
</script>

		<center>
			<h:form acceptcharset="UTF-8">
				<p:panel header="Gestione Company">
					<h:panelGrid columns="2" style="width: 95%">

						<h:outputLabel for="name" value="Nome (*):" style="width: 100%;" />
						<h:inputText id="name" value="#{companyController.element.name}"
							style="width: 100%;" required="true"
							requiredMessage="Nome obbligatorio!" />

						<h:outputLabel for="spot" value="Spot:" style="width: 100%;" />
						<h:inputText id="spot" value="#{companyController.element.spot}"
							style="width: 100%;" maxlength="50" size="50" />

						<h:outputLabel for="address" value="Indirizzo (*):"
							style="width: 100%;" />
						<h:inputText id="address"
							value="#{companyController.element.address}" style="width: 100%;"
							required="true" requiredMessage="Indirizzo obbligatorio!" />

						<h:outputLabel for="city" value="Citta' (*):" style="width: 100%;" />
						<h:inputText id="city" value="#{companyController.element.city}"
							style="width: 100%;" required="true"
							requiredMessage="Citta' obbligatorio!" />

						<h:outputLabel for="province" value="Provincia (*):"
							style="width: 100%;" />
						<h:inputText id="province"
							value="#{companyController.element.province}"
							style="width: 100%;" required="true"
							requiredMessage="Provincia obbligatorio!" />

						<h:outputLabel for="cap" value="Cap (*):" style="width: 100%;" />
						<h:inputText id="cap" value="#{companyController.element.cap}"
							style="width: 100%;" required="true"
							requiredMessage="Cap obbligatorio!" />

						<h:outputLabel for="telephone" value="Telefono:"
							style="width: 100%;" />
						<h:inputText id="telephone"
							value="#{companyController.element.telephone}"
							style="width: 100%;" />

						<h:outputLabel for="fax" value="fax:" style="width: 100%;" />
						<h:inputText id="fax" value="#{companyController.element.fax}"
							style="width: 100%;" />


						<h:outputLabel for="email" value="Email:" style="width: 100%;" />
						<h:inputText id="email" value="#{companyController.element.email}"
							style="width: 100%;" />
							
						<h:outputLabel for="emailNewsletter" value="Email per Newsletter:" style="width: 100%;" />
						<h:inputText id="emailNewsletter" value="#{companyController.element.emailNewsletter}"
							style="width: 100%;" />

						<h:outputLabel for="vat" value="P.IVA (*):" style="width: 100%;" />
						<h:inputText id="vat" value="#{companyController.element.vat}"
							style="width: 100%;" required="true"
							requiredMessage="P.IVA obbligatoria!" />

						<h:outputLabel for="lat" value="latitudine:" style="width: 100%;" />
						<h:inputText id="lat" value="#{companyController.element.lat}"
							style="width: 100%;" />

						<h:outputLabel for="lon" value="longitudine:" style="width: 100%;" />
						<h:inputText id="lon" value="#{companyController.element.lon}"
							style="width: 100%;" />

						<h:outputLabel for="video"
							value="video (nel formato http://www.youtube.com/v/xxxxxxxxxx):"
							style="width: 100%;" />
						<h:inputText id="video" value="#{companyController.element.video}"
							style="width: 100%;" />

						<h:outputLabel for="preview" value="Anteprima breve:" />
						<h:inputTextarea id="preview" cols="20" rows="20"
							value="#{companyController.element.preview}"
							style="height: 166px; width: 100%;" styleClass="tinyMceTa" />


						<h:outputLabel for="description" value="Descrizione:" />
						<h:inputTextarea id="description" cols="20" rows="20"
							value="#{companyController.element.description}"
							style="height: 166px; width: 100%;" styleClass="tinyMceTa" />


						<h:outputLabel for="secondaryAddress"
							value="Indirizzo Secondario:" />
						<h:inputTextarea
							value="#{companyController.element.secondaryAddress}"
							id="secondaryAddress" style=" height : 166px; width: 100%;" />

						<h:outputLabel for="telephoneNumbers" value="Numeri di Telefono:" />
						<h:inputTextarea
							value="#{companyController.element.telephoneNumbers}"
							id="telephoneNumbers" style=" height : 166px; width: 100%;" />

					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="4">
					<h:commandButton action="#{companyController.save}" value="Salva"
						immediate="false" rendered="#{not companyController.editMode}" />

					<h:commandButton action="#{companyController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{companyController.editMode}" />

					<h:commandButton action="#{companyController.delete}"
						value="Elimina" rendered="false" immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare?')) return false" />

				</h:panelGrid>
			</h:form>
		</center>


	</ui:define>
</ui:composition>